import req from '../utils/request';
import * as url from '../constants/api';

/**
 * @param { { mobile: string, code: string } } params
 * @returns { Promise<{ message: string, data: object }> }
 * @description 发送登录请求
 */
export function login (params) {
    return req({
        url: url.LOGIN,
        method: 'POST',
        data: params,
    });
}

/**
 * @returns { Promise<{ message: string, data: object }> }
 * @description 获取个人资料
 */
export function getUserProfile () {
    return req({
        url: url.USER_PROFILE,
        method: 'GET',
    });
}

/**
 * @returns { Promise<{ message: string, data: object }> }
 * @description 获取自己信息
 */
export function getUserInfo () {
    return req({
        url: url.USER_INFO,
        method: 'GET',
    });
}

/**
 * @param { string } mobile
 * @returns { Promise<{ message: string }> }
 * @description 获取验证码
 */
export function sendAuthCode (mobile) {
    return req({
        url: url.AUTH_CODE + mobile,
        method: 'GET',
    });
}
